import React from 'react';
import GopherProps from '../objects/internal/GopherProps';
import AsyncPaginatedTable from './AsyncPaginatedTable';
import { useTranslation } from 'react-i18next';

export interface OrderTableProps extends GopherProps {
	onSelection: (key: React.Key[]) => void;
}

export default function OrderTable(props: OrderTableProps) {
	const {t} = useTranslation();

	const dataFormat = [
		{
			title: t('table-header-id'),
			dataIndex: '_id',
		},
		{
			title: t('table-header-bike-id'),
			dataIndex: 'bikeId',
		},
		{
			title: t('table-header-username'),
			dataIndex: 'username',
		},
		{
			title: t('table-header-phone'),
			dataIndex: 'phone',
		},
		{
			title: t('table-header-mileage'),
			dataIndex: 'mileage',
		},
		{
			title: t('table-header-duration'),
			dataIndex: 'duration',
		},
		{
			title: t('table-header-state'),
			dataIndex: 'state',
		},
		{
			title: t('table-header-start-time'),
			dataIndex: 'startTime',
		},
		{
			title: t('table-header-subtotal'),
			dataIndex: 'subtotal',
		},
		{
			title: t('table-header-total'),
			dataIndex: 'total',
		},
	];

	return (
		<>
			<AsyncPaginatedTable dataFormat={dataFormat} fetch={props.gopher.listOrdersConverted.bind(props.gopher)} onSelection={props.onSelection}
								 gopher={props.gopher}/>
		</>
	);
}
